/*
 * Copyright (c) 2011. This file is public under GPLv3 license.
 * For more information about license please refer to http://www.gnu.org/licenses/gpl.html
 */

package com.freetools.watchdog.commands;

import com.freetools.watchdog.exceptions.ParametersErrorException;
import com.freetools.watchdog.model.CommandName;
import com.freetools.watchdog.model.IModelHolder;

import java.io.FileWriter;
import java.io.IOException;

/**
 * @author Michael Morozov
 */
@CommandName("spool")
public class SpoolCmd extends Command
{

    public void execute(IModelHolder model) throws ParametersErrorException
    {
        checkParameters();
        try
        {
            model.setSpool(new FileWriter(getParameters().get(0)));
        } catch (IOException e)
        {
            throw new ParametersErrorException(e);
        }
    }
}
